package com.example.mateproject.ui.activity

import android.os.Bundle
import android.util.Log
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.example.mateproject.databinding.ActivityTestLayoutBinding
import com.example.mateproject.ui.viewmodel.TestViewModel
import com.example.mateproject.ui.viewmodel.ViewModelFactory

class TestActivity : AppCompatActivity() {
    private lateinit var binding: ActivityTestLayoutBinding
    private lateinit var testViewModel: TestViewModel

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityTestLayoutBinding.inflate(layoutInflater)
        setContentView(binding.root)
        testViewModel = ViewModelProvider(this, ViewModelFactory(application))[TestViewModel::class.java]
//        binding.apply {
//            tvTest.text = intent.getIntExtra("current_position", 0).toString()
//        }
        Log.d("TestActivity", "onCreate: $testViewModel")
        testViewModel.position.observe(this, Observer { it->
            Toast.makeText(this@TestActivity,"$it",Toast.LENGTH_LONG).show()
            binding.tvTest.text = "$it"
        })
    }
}